package org.example.dto.base;

import java.util.List;

/**
 * @ Author     ：hanxi
 * @ Date       ：Created in 0:04 2020/12/13
 * @ Description：
 */

public class Page {
    private int currentPageNum;
    private int pageItemsCount;
    private int totalItemsCount;

    private int pageItemsStart;
    private int pageItemsEnd;
    private int pageCount;
    private boolean hasPrePage;
    private boolean hasNextPage;
    private int prePageNum;
    private int nextPageNum;
    private int firstPageNum;
    private int lastPageNum;
    private List dataList;

    public Page() {
        super();
    }

    public Page(int currentPageNum, int pageItemsCount, int totalItemsCount) {
        super();
        this.currentPageNum = currentPageNum;
        this.pageItemsCount = pageItemsCount;
        this.totalItemsCount = totalItemsCount;

        pageItemsStart = (currentPageNum - 1) * pageItemsCount;
        pageItemsEnd = pageItemsCount ;
        pageCount = (int) Math.ceil(totalItemsCount * 1.0 / pageItemsCount);
        firstPageNum = totalItemsCount > 0 ? 1 : 0;
        lastPageNum = totalItemsCount > 0 ? pageCount : 0;
        hasPrePage = currentPageNum > 1 ? true : false;
        hasNextPage = currentPageNum < lastPageNum ? true : false;
        prePageNum = hasPrePage ? currentPageNum - 1 : 0;
        nextPageNum = hasNextPage ? currentPageNum + 1 : 0;
    }

    public int getCurrentPageNum() {
        return currentPageNum;
    }

    public void setCurrentPageNum(int currentPageNum) {
        this.currentPageNum = currentPageNum;
    }

    public int getPageItemsCount() {
        return pageItemsCount;
    }

    public void setPageItemsCount(int pageItemsCount) {
        this.pageItemsCount = pageItemsCount;
    }

    public int getTotalItemsCount() {
        return totalItemsCount;
    }

    public void setTotalItemsCount(int totalItemsCount) {
        this.totalItemsCount = totalItemsCount;
    }

    public int getPageItemsStart() {
        return pageItemsStart;
    }

    public void setPageItemsStart(int pageItemsStart) {
        this.pageItemsStart = pageItemsStart;
    }

    public int getPageItemsEnd() {
        return pageItemsEnd;
    }

    public void setPageItemsEnd(int pageItemsEnd) {
        this.pageItemsEnd = pageItemsEnd;
    }

    public int getpageCount() {
        return pageCount;
    }

    public void setpageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public boolean isHasPrePage() {
        return hasPrePage;
    }

    public void setHasPrePage(boolean hasPrePage) {
        this.hasPrePage = hasPrePage;
    }

    public boolean isHasNextPage() {
        return hasNextPage;
    }

    public void setHasNextPage(boolean hasNextPage) {
        this.hasNextPage = hasNextPage;
    }

    public int getPrePageNum() {
        return prePageNum;
    }

    public void setPrePageNum(int prePageNum) {
        this.prePageNum = prePageNum;
    }

    public int getNextPageNum() {
        return nextPageNum;
    }

    public void setNextPageNum(int nextPageNum) {
        this.nextPageNum = nextPageNum;
    }

    public int getFirstPageNum() {
        return firstPageNum;
    }

    public void setFirstPageNum(int firstPageNum) {
        this.firstPageNum = firstPageNum;
    }

    public int getLastPageNum() {
        return lastPageNum;
    }

    public void setLastPageNum(int lastPageNum) {
        this.lastPageNum = lastPageNum;
    }

    public List getDataList() {
        return dataList;
    }

    public void setDataList(List dataList) {
        this.dataList = dataList;
    }
}